#!/usr/bin/node

const log = console.log;
const cp = require('child_process');

let son = cp.fork('./11-ipc-child.js');
let daughter = cp.fork('./11-ipc-child.js');

log(`i am your father Process: ${process.pid}`);

son.on('message',(data)=>{
  log(`I have a son:${data}`);
});

daughter.on('message',(data)=>{
  log(`I have a daughter:${data}`);
})

setTimeout(()=>{
  son.send('Good Good study')
},2000);

setTimeout(()=>{
  daughter.send('Day Day up');
},3000);

setTimeout(()=>{
  son.kill('SIGINT');
},5000);

setTimeout(()=>{
  daughter.kill('SIGINT')
},7000);
